package org.me.marble;

/**
 *
 * @author tungi
 */

public class Timer implements Runnable{
    private MoveMarble _move;
    private GameRenderer _renderer;

    private int _type;
    private boolean fired=true;

    public Timer(GameRenderer renderer,MoveMarble _mm){
        this._move=_mm;
        this._renderer=renderer;
    }

    public void setType(int type){
        this._type=type;
        fired=false;
    }
    
    public boolean isFired(){
        return fired;
    }

    public void fire(){
    	if(_type==timerTypes.fast.ordinal()){
            _move.modifySpeed(0.5);
            _renderer.setDeltaPointToDefault();
        }
        else if(_type==timerTypes.slow.ordinal()){
            _move.modifySpeed(2);
            _renderer.setDeltaPointToDefault();
        }
        else if(_type==timerTypes.block.ordinal()){
        	_move.modifySpeed(10.0f);
        }
        else if(_type==timerTypes.invert.ordinal()){
            _renderer.invert();
            _renderer.setDeltaPointToDefault();
        }      
    	fired=true;
    }
    
    public void run(){
        if(_type==timerTypes.fall.ordinal()){
            OptionsLibrary.started=false;
            GameActivity.game.endLevel(false);
        }
        else if(_type==timerTypes.endlevel.ordinal()){
            GameActivity.game.endLevel(true);
        }          
        fired=true;
    }
}
